package GUI;
/**
 * Principles select class screen for view personal data
 */
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JButton;


import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Vector;


public class PrincipleVpdSelClass extends JPanel {

	private JLabel lblPrincipleViewData = null;
	private JLabel lblSelectClass = null;
	private JComboBox cBSelClass = null;
	private JButton btnNext = null;
	
	public Login myLoginFrame = null;
	public static Dimension defaultDim=null;
	public UserPrinciple user=null;
	public PrincipleMainMenu prmn = null;
	
	private String selClass = null;
	private PrincipleVpdSelStudent selStudentScrn = null;
	
	
	
	
	
	public JComboBox getSelClassCb(PrincipleMainMenu prmn)
	{
		int i;
		Vector<String> classes = new Vector<String>();
		
		for(i=0;i<prmn.user.StudentsData.size();i++)
		{
			if((prmn.user.StudentsData.get(i).ClassId!=null)&&(!classes.contains(prmn.user.StudentsData.get(i).ClassId)))
			{
			classes.add(prmn.user.StudentsData.get(i).ClassId);
			System.out.println(prmn.user.StudentsData.get(i).ClassId);	
			}	
			
		}
		
		if(cBSelClass==null)
		{
			cBSelClass = new JComboBox(classes);
			cBSelClass.addActionListener(new ActionListener() {
			 	public void actionPerformed(ActionEvent arg0) {
			 		selClass = cBSelClass.getSelectedItem().toString();
			 		System.out.println(selClass);
			 	}
			 });
			cBSelClass.setBounds(224, 84, 168, 20);
				
		}
		return cBSelClass;
	}
	
	
	
	public JButton getNexBtn(final PrincipleMainMenu prmn)
	{
		if(btnNext==null)
		{
			 btnNext = new JButton("Next");
			 btnNext.addActionListener(new ActionListener() {
			 	public void actionPerformed(ActionEvent e) {
			 		prmn.user.setSelClass(selClass);
			 		selStudentScrn = null;
			 		selStudentScrn = prmn.getSelStudentScrn();
					prmn.setContentPane(selStudentScrn);
			 	}
			 });
				btnNext.setBounds(529, 309, 89, 23);
				
		}
		
		return btnNext;
	}
	

	private void initialize(PrincipleMainMenu prmn)
	{
		 setLayout(null);
			
		 lblPrincipleViewData = new JLabel("Principle view data");
		 lblPrincipleViewData.setBounds(397, 0, 89, 14);
		add(lblPrincipleViewData);
		
		lblSelectClass = new JLabel("Select Class:");
		lblSelectClass.setBounds(107, 87, 61, 14);
		add(lblSelectClass);
		add(getSelClassCb(prmn));
		add(getNexBtn(prmn));
		
	}
	public PrincipleVpdSelClass(PrincipleMainMenu prmn)
	{
		super();
		initialize(prmn);
		
		
	
	}
}
